import { objDeepCopy,getDateString } from "@/assets/js/common.js";
import commonObject from "@/assets/js/xm.js";
let Controller = {
	created() {
		this.init();
	},
	mounted() {
		
	},
	methods: {
		init() {
			this.getList(this);
			this.getQualityBox()
		},
		//获取下拉框数据
		getQualityBox(){
			this.$ajax({
				method: 'get',
				url:this.apiTest+'/supplier/supplierQualityRecord/getQualityBox',
				data:{}
			}).then(res=>{
				let data=res.data
				if(data.status == 200){
					let result = data.result
					this.Model.filterOption.items.forEach(item=>{
						
						switch(item.key){
							case 'duty'://责任归属
								let dutysKeys=Object.keys(result.dutys)
								dutysKeys.forEach(key=>{
									item.data.push({
										label:result.dutys[key],
										value:key
									})
								})
							break;
							case 'status'://质检状态
								let statusKeys=Object.keys(result.qualityStatus)
								statusKeys.forEach(key=>{
									item.data.push({
										label:result.qualityStatus[key],
										value:key
									})
								})
							break;
							case 'qualityController'://质检人
								let qualityControllerKeys=Object.keys(result.qualityController)
								qualityControllerKeys.forEach(key=>{
									item.data.push({
										label:result.qualityController[key],
										value:key
									})
								})
							break;
						}
					})
				}
			})
		},
		//获取列表
		getList(that,params,pageIndex = 1,pageSize = 10) {
			params = params || {};
			var apiTest = this.apiTest;
			this.$ajax({
					method: 'post',
					url:apiTest+'/supplier/supplierQualityRecordReturn/qualityReturnlist',
					data:{
						condition:params,
						pageIndex: pageIndex,
						pageSize: pageSize,
					}
			    }).then((res)=>{
					this.Model.tableData = [];
					var data = res.data;
					if(data.status == 200&&data.result){
						data.result.result.forEach((item,index)=>item.indexNumber=index+1)
						this.Model.tableData=data.result.result
					}else{
			
					}
				});
		},
		
		//新建调拨单
		newPage(){
			this.$router.push({
				path:'newReturnsOrder'
			});
		},
		//
		selectedHighlight(data) {
			// 如果选中则添加高亮样式
			if (this.Model.TableSelectData.indexOf(data.row) > -1) {
				return {
					"background-color": "#FEF6EE"
				};
				return {}
			}
		},
		warehousing(row) {
			this.Model.warehousingDialogStatus = row.status;
			this.Model.warehousingDialogFlag = true;
		},
		handleSelectionChange(val) {
			
		},
		handleCurrentChange(val) {
			var params = this.Model.searchFromData;
			this.getList(this,params,val);
		},
		handleSizeChange(val) {
			var params = this.Model.searchFromData;
			this.getList(this,params,undefined,val);
		},
		cardClick(color) {
			this.Model.cardSelected = color;
		},
		showChild(val) {
			this.Model.searchFromData = val;
		},
		toSearch(val) {
			var params = this.Model.searchFromData;
			this.getList(this,params);
		},
		toClear(val) {
			this.Model.searchFromData = {};
		},
		toExport(val) {
		  console.log(val);
		},
		tips(that,type,message) {
			that.$message({
				message: message,
				type: type
			});
		},
	},
	watch:{
		$route:{
		　　　handler(newValue, oldValue) {
				
		　　　},
		　　　deep: true
		},
  	
	},
	filters:{
		objFilters:function(value){
			
		}
	}
}
export default Controller;
